package com.baizhi.jh.service;

import com.baizhi.jh.dao.AdminDao;
import com.baizhi.jh.dao.UserDao;
import com.baizhi.jh.entity.Admin;
import com.baizhi.jh.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserDao userDao;

    @Override
    public Map<String, Object> queryAllPage(int page, int pageSize) {
        List<User> users= userDao.selectAllPage(page,pageSize);
        int totalCount=userDao.totalCount();
        Map map=new HashMap();
        map.put("total",totalCount);
        map.put("page",page);
        map.put("rows",users);
        return map;
    }

    @Override
    public Map<String, Object> update(User user) {
        userDao.update(user);
        Map<String,Object> map=new HashMap<String,Object>();
        if (user.getStatus().equals(1)) {
            map.put("message", "成功");
            map.put("status", 200);
        }else {
            map.put("message", "失败");
            map.put("status", 400);
        }
        return map;
    }
}
